########################################################################
# Microsoft (R) Debugging Information Dumper
#
# Copyright (c) Microsoft Corporation.  All rights reserved.
#
# File Comments:
#
########################################################################

CINC    = /I$(LANGAPI)\include /I$(LANGAPI)\shared /I..\..\..\include
CFLAGS  = /c /errorReport:send /FC /Fd$(ODIR)\cvdump.pdb /GF /Gy /Gz $(CINC) /W3 /Zc:wchar_t- /Zi $(EXTRA_CFLAGS)
LFLAGS  = /debug /dynamicbase /functionpadmin /largeaddressaware /map

MSPDB   = mspdb.lib

!if "$(CPU)" == ""
CPU     = $(PROCESSOR_ARCHITECTURE)
!endif

!ifdef  RELEASE
ODIR    = $(CPU)\release
CFLAGS  = $(CFLAGS) /DDBG=0 /DNDEBUG /MT /O2
LFLAGS  = $(LFLAGS) /debugtype:cv,fixup /incremental:no /opt:icf /opt:ref /release
CRTLIB  = msvcrt.lib
!else
ODIR    = $(CPU)\debug
CFLAGS  = $(CFLAGS) /DDBG=1 /D_DEBUG /MTd /Od /RTCc /RTCs /RTCu
CRTLIB  = msvcrtd.lib
!endif

!if     "$(CPU)" == "x86"
CFLAGS  = $(CFLAGS) /hotpatch
LFLAGS  = $(LFLAGS) /nxcompat /safeseh
!endif

.c{$(ODIR)}.obj::
        $(CC) $(CFLAGS) /Fo$(ODIR)\ $<

{../../../misc}.c{$(ODIR)}.obj::
        $(CC) $(CFLAGS) /Fo$(ODIR)\ $<

.cpp{$(ODIR)}.obj::
        $(CC) $(CFLAGS) /Fo$(ODIR)\ $<

.rc{$(ODIR)}.res:
        if exist $@ del $@
        rc -r -i$(LANGAPI)/include -Fo$@ $<

OBJS    = \
        $(ODIR)\cvdump.obj      \
        $(ODIR)\dumppdb.obj     \
        $(ODIR)\dumpsym6.obj    \
        $(ODIR)\dumpsym7.obj    \
        $(ODIR)\dumptyp6.obj    \
        $(ODIR)\dumptyp7.obj    \
        $(ODIR)\output.obj      \
        $(ODIR)\type6.obj       \
        $(ODIR)\type7.obj       \
        $(ODIR)\utils.obj       \
        $(ODIR)\utf8.obj        \
        $(ODIR)\cvdump.res


all: $(ODIR)\cvdump.exe


$(ODIR):
        @-mkdir $(ODIR)


$(ODIR)\cvdump.exe: $(ODIR) $(OBJS)
        link /errorreport:send @<<$(ODIR)\link.rsp
$(LFLAGS)
-out:$@
$(OBJS: = ^
)
$(MSPDB)
ole32.lib
oleaut32.lib
<<keep

clean:
    del /Q /F $(ODIR)\*.*

auto.dep: nul
        @-attrib -r auto.dep >nul $(STDERR_NULL)
        copy << auto.dep
#--------------------------------------------------------------------
# AUTOMATICALLY GENERATED BY MKDEP
#
# To regenerate dependencies, check out this file and then type
#     nmake /f pdb.mak auto.dep
#--------------------------------------------------------------------

<<
        mkdep -v $(CINC) -P $$(ODIR)\ -s .obj -n *.cpp > auto.tmp
        mkdep -v $(CINC) -P $$(ODIR)\ -s .res -n *.rc >> auto.tmp
# note well that the sed command below needs a TAB in the first
# substitution (TABs become spaces) otherwise, the subsequent
# substitution does not work correctly.
        sed <auto.tmp -e "s!	!   !" \
               -e "s! $(LANGAPI:\=/)/! $$(LANGAPI)/!g" >> auto.dep
        @-del auto.tmp
!if exist(auto.dep)
!include "auto.dep"
!else
cvdump.h:               $(LANGAPI)\include\cvexefmt.h $(LANGAPI)\include\cvinfo.h output.h $(LANGAPI)\include\pdb.h cvtdef.h

$(ODIR)\cvdump.obj:     cvdump.h $(LANGAPI)\include\version.h

$(ODIR)\dumpoledb.obj:  cvdump.h $(LANGAPI)\include\dbgoledb.h $(LANGAPI)\include\dbgoledbdecl.h

$(ODIR)\dumppdb.obj:    cvdump.h ..\..\..\include\szst.h ..\..\..\include\utf8.h

$(ODIR)\dumpsym6.obj:   cvdump.h debsym.h symrec.h

$(ODIR)\dumpsym7.obj:   cvdump.h ..\..\..\include\utf8.h

$(ODIR)\dumptyp6.obj:   cvdump.h

$(ODIR)\dumptyp7.obj:   cvdump.h

$(ODIR)\output.obj:     cvdump.h

$(ODIR)\type6.obj:      cvdump.h debsym.h typeinfo.h

$(ODIR)\type7.obj:      cvdump.h

$(ODIR)\utils.obj:      cvdump.h
!endif
